home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / novia / bin / openport.c < prev    next >
C/C++ Source or Header  |  1999-12-06  |  2KB  |  64 lines

  1. #include <pragma/noviasys_lib.h>
  2. #include <pragma/exec_lib.h>
  3. #include <pragma/dos_lib.h>
  4. #include <stdio.h>
  5. #include <novia/novia_portdata.h>
  6.  
  7. struct Library *NoviaSysBase;
  8.  
  9. void ioprintf(const char *string, ...)
  10. {
  11.     char *buffer=AllocVec(10000,MEMF_ANY|MEMF_CLEAR);
  12.     if (buffer)
  13.     {
  14.         vsprintf(buffer, string, unsigned int(&string + 1));
  15.         Writeio(buffer,-1);
  16.         FreeVec(buffer);
  17.     }
  18. }
  19.  
  20. void main()
  21. {
  22.     if ((NoviaSysBase = OpenLibrary("noviasys.library", 0)))
  23.     {
  24.         struct PortData *cport = (struct PortData *)FindTask(NULL)->tc_UserData;
  25.             if (cport->systemservice)
  26.             {
  27.                 UBYTE *table;
  28.                 UBYTE invalid=TRUE;
  29.                 if ((table=AllocVec(10000,MEMF_ANY|MEMF_CLEAR)))
  30.                 {
  31.                     SelectFromTo(table+1,9999,cport->argstring[1]);
  32.                     nc=(PortData2 *)client_list->lh_Head;
  33.                     while (nc->port_node.ln_Succ)
  34.                     {
  35.                         if (table[nc->port_address->clientconfig.IDNumber])
  36.                         {
  37.                             cport2=nc->port_address;
  38.                             Writeio("loadport: ",-1);
  39.                             Writelong(cport2->clientconfig.IDNumber);
  40.                             LF();
  41.                             if (cport2->PortStatus==PORT_STATUS_CLOSE)
  42.                             {
  43.                                 cport2->PortStatus=PORT_STATUS_WAITLOAD;
  44.                                 CreateClient(cport2);
  45.                             }
  46.                             else
  47.                             {
  48.                                 SendMsg(cport2->LocalPort,0,0,MSG_PORT_TOFRONT,0);
  49.                             }
  50.                             invalid=FALSE;
  51.                         }
  52.                         nc=(PortData2 *)nc->port_node.ln_Succ;
  53.                     }
  54.                     if (invalid)
  55.                     {
  56.                         ioprintf("USAGE: OpenPort #IDNumber(s)\n");
  57.                         ioprintf("    Example: OP 1-3,8-,5  (Open Port 1,2,3,5,8 and all other Ports higher 8.)\n");
  58.                     }
  59.                     FreeVec(table);
  60.                 } 
  61.                 return TRUE;
  62.             }        CloseLibrary(NoviaSysBase);
  63.     }
  64. }